package cn.aylog.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SomeController {

    @Autowired
    private RedisTemplate<Object, Object> redis;

    @RequestMapping("/hello")
    public String hello() {
        redis.opsForValue().set("age", 20);
        Object age = redis.opsForValue().get("age");
        System.out.println(age);
        return "SUCCESS";
    }

    @RequestMapping("/setData")
    public String setData(@RequestParam Integer age) {
        redis.opsForValue().set("age", age);
        return "SUCCESS";
    }

    @RequestMapping("/getData")
    public String getData() {
        Object age = redis.opsForValue().get("age");
        return age.toString();
    }

}
